package member;

import java.io.Reader;
import java.sql.Timestamp;
import java.util.List;
import java.util.ArrayList;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import com.opensymphony.xwork2.ActionSupport;

import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;
import com.opensymphony.xwork2.ActionContext;

public class membermodifyAction extends ActionSupport implements SessionAware{
	
	public static Reader reader;
	public static SqlMapClient sqlMapper;
	
	private Memberbean param;
	
	private String m_id;
	private String m_nickname;
	private String m_pw;
	private String m_name;
	private String m_idnum;
	private String m_email;
	private String m_hp;
	private String m_addr1;
	private String m_addr2;
	private String zipcode;
	
	Map session;
	
	public membermodifyAction() throws Exception{
		reader = Resources.getResourceAsReader("sqlMapConfig.xml");
		sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
		reader.close();
	}
	public String form() throws Exception{
		
		return SUCCESS;
	}
	
	public String execute() throws Exception{
		
		ActionContext context=ActionContext.getContext();
		Map<String,Object> session = context.getSession();
		
		if(session.size() > 0){
			String id=(String)session.get("session_m_id");
			param = (Memberbean) sqlMapper.queryForObject("getMember", id);
			
			param.setM_id(getM_id());
			param.setM_nickname(getM_nickname());
			param.setM_pw(getM_pw());
			param.setM_name(getM_name());
			param.setM_idnum(getM_idnum());
			param.setM_email(getM_email());
			param.setM_hp(getM_hp());
			param.setM_addr1(getM_addr1());
			param.setM_addr2(getM_addr2());
			param.setZipcode(getZipcode());
			
			sqlMapper.update("updateMember", param);
		}
		return SUCCESS;
	}
	public Memberbean getParam() {
		return param;
	}
	public void setParam(Memberbean param) {
		this.param = param;
	}
	public String getM_id() {
		return m_id;
	}
	public void setM_id(String m_id) {
		this.m_id = m_id;
	}
	public String getM_nickname() {
		return m_nickname;
	}
	public void setM_nickname(String m_nickname) {
		this.m_nickname = m_nickname;
	}
	public String getM_pw() {
		return m_pw;
	}
	public void setM_pw(String m_pw) {
		this.m_pw = m_pw;
	}
	public String getM_name() {
		return m_name;
	}
	public void setM_name(String m_name) {
		this.m_name = m_name;
	}
	public String getM_idnum() {
		return m_idnum;
	}
	public void setM_idnum(String m_idnum) {
		this.m_idnum = m_idnum;
	}
	public String getM_email() {
		return m_email;
	}
	public void setM_email(String m_email) {
		this.m_email = m_email;
	}
	public String getM_hp() {
		return m_hp;
	}
	public void setM_hp(String m_hp) {
		this.m_hp = m_hp;
	}
	public String getM_addr1() {
		return m_addr1;
	}
	public void setM_addr1(String m_addr1) {
		this.m_addr1 = m_addr1;
	}
	public String getM_addr2() {
		return m_addr2;
	}
	public void setM_addr2(String m_addr2) {
		this.m_addr2 = m_addr2;
	}
	public String getZipcode() {
		return zipcode;
	}
	public void setZipcode(String zipcode) {
		this.zipcode = zipcode;
	}
	public Map getSession() {
		return session;
	}
	public void setSession(Map session) {
		this.session = session;
	}
}